<%@page import="java.util.List"%>
<%@page import="com.jju.A1541.dao.User1DAO"%>
<%@page import="com.jju.A1541.model.User1"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人资料</title>
</head>
<body>
<%
String username =(String)session.getAttribute("u");
User1 user1 = User1DAO.login(username);
if(user1==null){
out.println("<div class=' col-md-8 publish wow fadeInUp' id='my'><!-- 将数据appendTo tbody 定义id -->"+
    "<form class='form-horizontal' action='my_add_save.jsp'"+
          "method='post'>"+
        "<div class='form-group'>"+
            "<label  class='col-sm-2'>昵称:</label>"+
            "<div class='col-sm-7 dropdown'>"+
                "<input type='text' name='uname' placeholder='请填写您的姓名或昵称' required=''>"+
            "</div>"+
            "</div>"+
        "<div class='form-group'>"+
            "<label  class='col-sm-2'>性别:</label>"+
            "<div class='col-sm-7 dropdown' >"+
                "<select name='sex'>"+
                    "<option></option>"+
                    "<option>男</option>"+
                    "<option>女</option>"+
                "</select>"+
            "</div>"+
        "</div>"+
        "<div class='form-group'>"+
            "<label  class='col-sm-2'>所在学院:</label>"+
            "<div class='col-sm-7 dropdown' >"+
                "<select name='ejxy'>"+
                    "<option></option>"+
                    "<option>经济与管理学院</option>"+
                    "<option>电子商务学院</option>"+
                "    <option>政法学院</option>"+
                "    <option>文学与传媒学院</option>"+
                "    <option>外国语学院</option>"+
                "    <option>理学院</option>"+
                "    <option>化学与环境工程学院</option>"+
                "    <option>机械与材料工程学院</option>"+
                "    <option>电子工程学院</option>"+
                "    <option>信息科学与技术学院</option>"+
                 "   <option>土木工程与城市建设学院</option>"+
                 "   <option>艺术学院</option>"+
                "    <option>药学与生命科学学院</option>"+
                "    <option>基础医学院</option>"+
                "    <option>会计学院</option>"+
                "    <option>旅游与国土资源学院</option>"+
                 "   <option>体育学院</option>"+
                 "   <option>护理学院</option>"+
                "    <option>临床医学院</option>"+
                 "   <option>师范学院</option>"+
                "    <option>马克思主义学院</option>"+
                "</select>"+
          "  </div>"+
       " </div>"+
       " <div class='form-group'>"+
           " <label  class='col-sm-2'>个人说明:</label>"+
            "<div class='col-sm-7 dropdown'>"+
                "<textarea rows='1' cols='50' name='grjj'></textarea>"+
                "<span	class='help-block'></span> </div>"+
        "</div>"+
       "<br/>"+
        "<br/>"+
        "<button type='submit'  class='btn btn-primary  col-sm-2 col-md-offset-2' id='expaddbtn'>保存信息</button>"+
    "</form>"+
"</div>");
}else{
	String keyword="";
	List<User1> data =null;
	//区分访问该页面是直接访问 还是表单查询提交
	if(username==null){
	  data =User1DAO.getAll(); //取所有记录
	} else { //传递了关键字,根据关键字查询
	  keyword = username;
	//通过String类的构造方法，指定的字符串为“UTF-8”编码
	  data =User1DAO.getByKeyword(keyword);
	}
	      //遍历系统中所有的捐赠信息
	     for(User1 obj:data){
	     	 out.println("<div class='form-group'>"+
	                 "<label  class='col-sm-2'>昵称:</label>"+obj.getUname()+
	                 "<div class='form-group'>"+
	                 "<label  class='col-sm-2'>性别:</label>"+obj.getSex()+
	                 "<div class='form-group'>"+
	                 "<label  class='col-sm-2'>所在学院:</label>"+obj.getEjxy()+
	                 " <div class='form-group'>"+
	                 " <label  class='col-sm-2'>个人说明:</label>"+obj.getGrjj()+
	                 "<br>"+
	                 "<a href='my_edit.jsp?username="+username+"'>修改</a> "
	     			 );
	     	 
	     }
}
%>
</body>
</html>